import request from "@/utils/request";
import { stringify } from "qs";
/****************************** sku商品 ***********************************/
//获取列表分页
export async function getGoodsSkuPage(params) {
	return request(`/new-goods/goods/sku/list`, {
        method: "Post",
		data: params,
        loading: true 
    });
}
//获取sku详细信息
export async function getInfoGoodsSku(params) {
	return request(`/new-goods/goods/sku/get-info?${stringify(params)}`, { loading: true });
}

// 编辑系统款式sku
export async function goodsSkuSubmit(params) {
	return request(`/new-goods/goods/sku/submit`, { method: "Post", data: params, loading: true });
}
// 启/禁用同步库存;
export async function enableSyncGoodsSku(params) {
	return request(`/new-goods/ec-goods-sku/stock/enable-sync`, { method: "Post", data: params, loading: true });
}
//批量删除sku
export async function batchDelGoodsSku(params) {
	return request(`/new-goods/goods/sku/batch-del`, { method: "Post", data: params, loading: true });
}
//批量修改sku商品信息
export async function batchUpdateGoodsSkuInfo(params) {
	return request(`/new-goods/goods/sku/batch-update`, { method: "Put", data: params, loading: true });
}
//批量修改sku状态
export async function batchUpdateStatusGoodsSku(params) {
	return request(`/new-goods/goods/sku/batch-update-status`, { method: "Put", data: params, loading: true });
}
//批量修改sku商品备注
export async function batchUpdateNoteGoodsSku(params) {
	return request(`/new-goods/goods/sku/batch-update-note`, { method: "Put", data: params, loading: true });
}
// 根据商品编码修改采购价
// type  1 成本价  2 采购价
export async function updatePriceSku(params) {
	return request(`/new-goods/goods/sku/log/update-price`, { method: "Post", data: params, loading: true });
}
// 历史成本价/采购价列表
export async function getGoodsSkuLogList(params) {
	return request(`/new-goods/goods/sku/log/list?${stringify(params)}`, { loading: true });
}
//设置默认跑量商品
export async function setRunningVolumeSku(params) {
	return request(`/new-goods/goods/sku/set-running-volume`, { method: "Post", data: params, loading: true });
}
//根据系统id sku同步库存到店铺
export async function setBatchSyncSku(params) {
	return request(`/new-goods/ec-goods-sku/stock/batch-sync-stock-by-sys-sku-ids`, {
		method: "Post",
		data: params,
		loading: true
	});
}
//根据系统id spu同步库存到店铺
export async function setBatchSyncSpu(params) {
	return request(`/new-goods/ec-goods-sku/stock/batch-sync-stock-by-sys-spu-ids`, {
		method: "Post",
		data: params,
		loading: true
	});
}
// 删除历史采购价/成本价
export async function deleteGoodsSkuLog({ id }) {
	return request(`/new-goods/goods/sku/log/${id}`, {
		method: "delete"
	});
}
// 获取待匹配商品数量
export async function getSkuNotMatchNum(params) {
	return request(`/new-goods/goods/sku/get-not-match-num?${stringify(params)}`, { loading: true });
}
// sku日志
export async function getGoodsSystemSkuLogPage(params) {
	return request(`/new-goods/logs/goods/sku/page?${stringify(params)}`, {});
}
// spu日志
export async function getGoodsSystemSpuLogPage(params) {
	return request(`/new-goods/logs/goods/spu/page?${stringify(params)}`, {});
}

//更换匹配
export async function changeGoodsSkuMatch(params) {
	return request(`/new-goods/goods/sku/update-match`, {
		method: "Post",
		data: params,
		loading: true
	});
}
//解除匹配  {id}
export async function removeGoodsSkuMatch(params) {
	return request(`/new-goods/goods/sku/remove-match`, {
		method: "Post",
		data: params,
		loading: true
	});
}
//设置默认  {id}
export async function setDefaultGoodsSkuMatch(params) {
	return request(`/new-goods/goods/sku/set-default`, {
		method: "Post",
		data: params,
		loading: true
	});
}
//批量解除默认匹配
export async function batchRemoveDefaultMatchOp(params) {
	return request(`/new-goods/goods/sku/remove-goods-match `, {
		method: "Post",
		data: params,
		loading: true
	});
}

/****************************** sku商品 ***********************************/

/****************************** 款式商品 ***********************************/
export async function getGoodsSpuPage(params) {
	return request(`/new-goods/goods/spu/list`, { 
        method: "Post",
		data: params,
        loading: true 
    });
}
//款式商品新增/编辑接口
export async function goodsSpuSubmit(params) {
	return request(`/new-goods/goods/spu/submit`, { method: "Post", data: params, loading: true });
}
// 查询spu商品详细信息
export async function getInfoGoodsSpu(params) {
	return request(`/new-goods/goods/spu/get-info?${stringify(params)}`, { loading: true });
}
// 启/禁用同步库存;
export async function enableSyncGoodsSpu(params) {
	return request(`/new-goods/goods/stock/enable-sync`, { method: "Post", data: params, loading: true });
}
//批量删除spu
export async function batchDelGoodsSpu(params) {
	return request(`/new-goods/goods/spu/batch-del`, { method: "Put", data: params, loading: true });
}
//批量修改spu状态
export async function batchUpdateStatusGoodsSpu(params) {
	return request(`/new-goods/goods/spu/batch-update-status`, { method: "Put", data: params, loading: true });
}
//批量修改spu商品信息
export async function batchUpdateGoodsSpuInfo(params) {
	return request(`/new-goods/goods/spu/batch-update`, { method: "Put", data: params, loading: true });
}
// 获取待匹配商品数量
export async function getSpuNotMatchNum(params) {
	return request(`/new-goods/goods/spu/get-not-match-num?${stringify(params)}`, { loading: true });
}
/****************************** 款式商品 ***********************************/

/****************************** 分类属性 ***********************************/
// 查询分类属性列表接口
export async function getGoodsAttribute(params) {
	return request(`/new-goods/goods/attribute/find-all`);
}
// 新增/编辑分类属性接口
export async function goodsAttributeSubmit(params) {
	return request(`/new-goods/goods/attribute/submit`, { method: "Post", data: params, loading: true });
}
// 查询分类详细接口
export async function getGoodsAttributeInfo(params) {
	return request(`/new-goods/goods/attribute/get-info?${stringify(params)}`, { loading: true });
}
// 修改分类属性状态
export async function updateGoodsAttributeStatus(params) {
	return request(`/new-goods/goods/attribute/update-status`, { method: "Post", data: params, loading: true });
}
// 删除分类属性状态
export async function delGoodsAttributeStatus(id) {
	return request(`/new-goods/goods/attribute/del?id=${id}`, { method: "Post", loading: true });
}
/****************************** 分类属性 ***********************************/
// 获取导入模板的下载路径
export async function getImportTemplateUrl(params) {
	return request(`/blade-log/taskInfo/getImportTemplateUrl?${stringify(params)}`, { loading: true });
}

export async function manuallySynchronizeStoreProducts(params) {
	return request(`/new-goods/ec-goods-sku/sync-ec-goods-sku-by-hand?${stringify(params)}`, {
		loading: true
	});
}

// 快捷查询相关
export async function quickQueryLabelGetByCode(params) {
	return request(`/new-common/quickQueryLabel/getByCode?${stringify(params)}`, {
		loading: false
	});
}
export async function quickQueryLabelSaveOrUpdate(params) {
	return request(`/new-common/quickQueryLabel/saveOrUpdate`, {
		method: "post",
		data: params,
		loading: true
	});
}
// 退货去向
export async function setReturnDestination(params) {
	return request(`/new-goods/goods/sku/update-re-destination`, {
		method: "post",
		data: params,
		loading: true
	});
}
// sku同步/禁止状态
export async function updateSkuSyncStatus(params) {
	return request(`/new-goods/goods/sku/batch-update-sync-status`, {
		method: "put",
		data: params,
		loading: true
	});
}
// sku同步/禁止状态
export async function updateSpuSyncStatus(params) {
	return request(`/new-goods/goods/spu/batch-update-sync-status`, {
		method: "put",
		data: params,
		loading: true
	});
}
// 查询生成系统商品规则配置
export async function getGenerateRulesConfig(params) {
	return request(`/new-goods/generate-rules-config/byUuid?${stringify(params)}`, {
		loading: false
	});
}
// 保存生成系统商品规则配置
export async function saveGenerateRulesConfig(params) {
	return request(`/new-goods/generate-rules-config/save`, {
		method: "POST",
		data: params,
		loading: true
	});
}
// 根据合格证id查询合格证模板批量
export async function queryDefaultTemplate(params) {
	return request(`/blade-goods/foreign/getCoFcTemplateByIds`, {
		method: "POST",
		data: params || [1],
		loading: true
	});
}
// 设置合格证
export async function setTemplate(params) {
	return request(`/new-goods/goods/sku/set-template`, {
		method: "POST",
		data: params,
		loading: true
	});
}

// 获取模板列表
export async function queryLabelTemplate(params) {
	return request(`/new-common/labelTemplate/list`, {
		method: "post",
		data: params,
	});
}

//解除匹配-new
export async function cancelMatch(params) {
	return request(`/new-goods/goods/sku/remove-goods-match-batch`, {
		method: "Post",
		data: params,
	});
}